// 使用 Vite 的 glob 导入所有 SVG
const logos = import.meta.glob('@/assets/images/conn/*.svg', { eager: true })

// 获取 logo key
const getLogoKey = (path: string): string => {
  const matches = path.match(/\/([^/]+)\.svg$/)
  return matches ? matches[1].toLowerCase() : ''
}

// 创建 logo 映射
export const logoMap: Record<string, string> = Object.entries(logos).reduce((acc, [path, module]: [string, any]) => {
  const key = getLogoKey(path)
  acc[key] = module.default
  return acc
}, {} as Record<string, string>)

/**
 * 获取数据库类型对应的 logo
 * @param type 数据库类型
 * @returns logo URL
 */
export const getLogoByType = (type: string): string => {
  return logoMap[type.toLowerCase()] || ''
}